package edu.nctu.csie.jichang.dp.behavioral;

public class Visitor {
	public static void main(String[] args) {
		VisitorUser tVisitorUser = new VisitorUser();
		tVisitorUser.visit(new PlaceA());
		tVisitorUser.visit(new PlaceB());
		tVisitorUser.visit(new PlaceC());
	}
}
interface IVisitor{
	void visit(PlaceA pPlaceA);
	void visit(PlaceB pPlaceB);
	void visit(PlaceC pPlaceC);
}
interface IPlace{
	void visit(IVisitor pVisitor);
}
class PlaceA implements IPlace{
	public void visit(IVisitor pVisitor) {pVisitor.visit(this);}
	public void showName(){System.out.println("This is PlaceA");};
}
class PlaceB implements IPlace{
	public void visit(IVisitor pVisitor) {pVisitor.visit(this);}
	public void name(){System.out.println("This is PlaceB");};
}
class PlaceC implements IPlace{
	public void visit(IVisitor pVisitor) {pVisitor.visit(this);}
	public void show(){System.out.println("This is PlaceC");};
}
class VisitorUser implements IVisitor{
	public void visit(PlaceA pPlaceA) {pPlaceA.showName();}
	public void visit(PlaceB pPlaceB) {pPlaceB.name();}
	public void visit(PlaceC pPlaceC) {pPlaceC.show();}
}